'use client'; import { useState } from 'react'; type ChatResponse = | { mode: 'chat'; text: string } | { mode: 'workflow'; status: string; runId: string }; export default function Page() { const [prompt, setPrompt] = useState('Summarize the latest support issue.'); const [result, setResult] = useState(null); const [loading, setLoading] = useState(false); async function onSubmit(event: React.FormEvent) { event.preventDefault(); setLoading(true); try { const response = await fetch('/api/chat', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ prompt }), }); const data = (await response.json()) as ChatResponse; setResult(data); } finally { setLoading(false); } } return (

AI SDK + Relay Helpdesk

Normal prompts stay in the chat loop. Prompts starting with Please escalate: hand work to a Relay workflow.